var api = require('../../utils/api.js');
var app = getApp();
Page({
    /**
     * 页面的初始数据 user_money_tx
     */
    data: {
        show:1,
        bankname:'',
        banknumber:'',
        username:'',
    },
    getbankname(ret){
        this.setData({bankname:ret.detail.value})
    },
    getbanknumber(ret){
        this.setData({banknumber:ret.detail.value})
    },
    getusername(ret){
        this.setData({username:ret.detail.value})
    },

    onShow() {
        this.getworkerinfo();
    },

    getworkerinfo(){
        var that=this;

        api.post({
            url: 'user/index',
            data: {},
            success: data => {
                that.setData({
                    info:data.data
                })
            }
        })

    },
    getlastlog(){
        var that=this;
        api.post({
            url: 'user/getlastlog',
            data: {},
            success: data => {
                console.log(data);

            }
        })
    },

    sumbmits(){
        var that=this;
        var show=this.data.show;

        var bankname=this.data.bankname;
        var banknumber=this.data.banknumber;
        var username=this.data.username;
        that.setData({
            show:0
        })
        if(!show){
            return false;
        }
        
        api.post({
            url: 'user/getmoneytobank',
            data: {bankname:bankname,banknumber:banknumber,username:username},
            success: data => {
                that.getworkerinfo();

                wx.showToast({
                  title: data.msg,
                  icon:'none'
                })
                that.setData({
                    show:1
                })
            }
        })


    }
})